home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 116_01.zip / VERB.C < prev    next >
Text File  |  1993-06-19  |  12KB  |  890 lines

  1.  
  2.  /* VERB.C  no mods for V 1.43 */
  3. #include "advent.h"
  4.  
  5. /*
  6.     Routine to process a transitive verb
  7. */
  8. trverb()
  9. {
  10.     switch(verb){
  11.     case CALM:
  12.     case WALK:
  13.     case QUIT:
  14.     case SCORE:
  15.     case FOO:
  16.     case BRIEF:
  17.     case SUSPEND:
  18.     case HOURS:
  19.     case LOG:
  20.         actspk(verb);
  21.         break;
  22.     case TAKE:
  23.         vtake();
  24.         break;
  25.     case DROP:
  26.         vdrop();
  27.         break;
  28.     case OPEN:
  29.     case LOCK:
  30.         vopen();
  31.         break;
  32.     case SAY:
  33.         vsay();
  34.         break;
  35.     case NOTHING:
  36.         rspeak(54);
  37.         break;
  38.     case ON:
  39.         von();
  40.         break;
  41.     case OFF:
  42.         voff();
  43.         break;
  44.     case WAVE:
  45.         vwave();
  46.         break;
  47.     case KILL:
  48.         vkill();
  49.         break;
  50.     case POUR:
  51.         vpour();
  52.         break;
  53.     case EAT:
  54.         veat();
  55.         break;
  56.     case DRINK:
  57.         vdrink();
  58.         break;
  59.     case RUB:
  60.         if(object!=LAMP)
  61.             rspeak(76);
  62.         else
  63.             actspk(RUB);
  64.         break;
  65.     case THROW:
  66.         vthrow();
  67.         break;
  68.     case FEED:
  69.         vfeed();
  70.         break;
  71.     case FIND:
  72.     case INVENTORY:
  73.         vfind();
  74.         break;
  75.     case FILL:
  76.         vfill();
  77.         break;
  78.     case READ:
  79.         vread();
  80.         break;
  81.     case BLAST:
  82.         vblast();
  83.         break;
  84.     case BREAK:
  85.         vbreak();
  86.         break;
  87.     case WAKE:
  88.         vwake();
  89.         break;
  90.     default:
  91.         printf("This verb is not implemented yet.\n");
  92.     }
  93. }
  94.  
  95. /*
  96.     CARRY TAKE etc.
  97. */
  98. vtake()
  99. {
  100.     char msg;
  101.     int i;
  102.  
  103.     if(toting(object)) {
  104.         actspk(verb);
  105.         return;
  106.     }
  107.     /*
  108.        special case objects and fixed objects
  109.     */
  110.     msg=25;
  111.     if(object==PLANT && prop[PLANT] <= 0)
  112.         msg=115;
  113.     if(object==BEAR && prop[BEAR]==1)
  114.         msg=169;
  115.     if(object==CHAIN && prop[BEAR]!=0)
  116.         msg=170;
  117.     if(fixed[object]) {
  118.         rspeak(msg);
  119.         return;
  120.     }
  121.     /*
  122.        special case for liquids
  123.     */
  124.     if(object==WATER || object==OIL) {
  125.         if(!here(BOTTLE) || liq()!=object) {
  126.             object=BOTTLE;
  127.             if(toting(BOTTLE)&&prop[BOTTLE]==1){
  128.                 vfill();
  129.                 return;
  130.             }
  131.             if(prop[BOTTLE]!=1)
  132.                 msg=105;
  133.             if(!toting(BOTTLE))
  134.                 msg=104;
  135.             rspeak(msg);
  136.             return;
  137.         }
  138.         object=BOTTLE;
  139.     }
  140.     if(holding>=7) {
  141.         rspeak(92);
  142.         return;
  143.     }
  144.     /*
  145.        special case for bird.
  146.     */
  147.     if(object==BIRD && prop[BIRD]==0) {
  148.         if(toting(ROD)) {
  149.             rspeak(26);
  150.             return;
  151.         }
  152.         if(!toting(CAGE)) {
  153.             rspeak(27);
  154.             return;
  155.         }
  156.         prop[BIRD]=1;
  157.     }
  158.     if( (object==BIRD || object==CAGE) &&
  159.         prop[BIRD]!=0)
  160.         carry((BIRD+CAGE)-object,loc);
  161.     carry(object,loc);
  162.     /*
  163.        handle liquid in bottle
  164.     */
  165.     i=liq();
  166.     if(object==BOTTLE && i!=0)
  167.         place[i]=-1;
  168.     rspeak(54);
  169. }
  170.  
  171. /*
  172.     DROP etc.
  173. */
  174. vdrop()
  175. {
  176.     int i;
  177.  
  178.     /*
  179.        check for dynamite
  180.     */
  181.     if(toting(ROD2) && object==ROD && !toting(ROD))
  182.         object=ROD2;
  183.     if(!toting(object)){
  184.         actspk(verb);
  185.         return;
  186.     }
  187.     /*
  188.        snake and bird
  189.     */
  190.     if(object==BIRD && here(SNAKE)) {
  191.         rspeak(30);
  192.         if(closed)
  193.             dwarfend();
  194.         dstroy(SNAKE);
  195.         prop[SNAKE]=-1;
  196.     }
  197.     /*
  198.        coins and vending machine
  199.     */
  200.     else if(object==COINS && here(VEND)) {
  201.         dstroy(COINS);
  202.         drop(BATTERIES,loc);
  203.         pspeak(BATTERIES,0);
  204.         return;
  205.     }
  206.     /*
  207.        bird and dragon (ouch!!)
  208.     */
  209.     else if(object==BIRD && at(DRAGON) && prop[DRAGON]==0){
  210.         rspeak(154);
  211.         dstroy(BIRD);
  212.         prop[BIRD] = 0;
  213.         if(place[SNAKE]!=0)
  214.             ++tally2;
  215.         return;
  216.     }
  217.     /*
  218.        Bear and troll
  219.     */
  220.     if(object==BEAR && at(TROLL)) {
  221.         rspeak(163);
  222.         move(TROLL,0);
  223.         move((TROLL+MAXOBJ),0);
  224.         move(TROLL2,117);
  225.         move((TROLL2+MAXOBJ),122);
  226.         juggle(CHASM);
  227.         prop[TROLL]=2;
  228.     }
  229.     /*
  230.        vase
  231.     */
  232.     else if(object==VASE) {
  233.         if(loc==96)
  234.             rspeak(54);
  235.         else {
  236.             prop[VASE] = at(PILLOW) ? 0 : 2;
  237.             pspeak(VASE,prop[VASE]+1);
  238.             if(prop[VASE]!=0)
  239.                 fixed[VASE]=-1;
  240.         }
  241.     }
  242.     /*
  243.        handle liquid and bottle
  244.     */
  245.     i=liq();
  246.     if(i==object)
  247.         object=BOTTLE;
  248.     if(object==BOTTLE && i!=0)
  249.         place[i]=0;
  250.     /*
  251.        handle bird and cage
  252.     */
  253.     if(object==CAGE && prop[BIRD]!=0)
  254.         drop(BIRD,loc);
  255.     if(object==BIRD)
  256.         prop[BIRD]=0;
  257.     drop(object,loc);
  258. }
  259.  
  260. /*
  261.     LOCK, UNLOCK, OPEN, CLOSE etc.
  262. */
  263. vopen()
  264. {
  265.     char msg,oyclam;
  266.  
  267.     switch(object) {
  268.     case CLAM:
  269.     case OYSTER:
  270.         oyclam=(object==OYSTER ? 1 : 0);
  271.         if(verb==LOCK)
  272.             msg=61;
  273.         else if(!toting(TRIDENT))
  274.             msg=122+oyclam;
  275.         else if(toting(object))
  276.             msg=120+oyclam;
  277.         else {
  278.             msg=124+oyclam;
  279.             dstroy(CLAM);
  280.             drop(OYSTER,loc);
  281.             drop(PEARL,105);
  282.         }
  283.         break;
  284.     case DOOR:
  285.         msg=(prop[DOOR]==1 ? 54 : 111);
  286.         break;
  287.     case CAGE:
  288.         msg=32;
  289.         break;
  290.     case KEYS:
  291.         msg=55;
  292.         break;
  293.     case CHAIN:
  294.         if(!here(KEYS))
  295.             msg=31;
  296.         else if(verb==LOCK) {
  297.             if(prop[CHAIN]!=0)
  298.                 msg=34;
  299.             else if(loc!=130)
  300.                 msg=173;
  301.             else {
  302.                 prop[CHAIN]=2;
  303.                 if(toting(CHAIN))
  304.                     drop(CHAIN,loc);
  305.                 fixed[CHAIN]= -1;
  306.                 msg=172;
  307.             }
  308.         }
  309.         else {
  310.             if(prop[BEAR]==0)
  311.                 msg=41;
  312.             else if(prop[CHAIN]==0)
  313.                 msg=37;
  314.             else {
  315.                 prop[CHAIN]=0;
  316.                 fixed[CHAIN] = 0;
  317.                 if(prop[BEAR]!=3)
  318.                     prop[BEAR]=2;
  319.                 fixed[BEAR]=2-prop[BEAR];
  320.                 msg=171;
  321.             }
  322.         }
  323.         break;
  324.     case GRATE:
  325.         if(!here(KEYS))
  326.             msg=31;
  327.         else if(closing) {
  328.             if(!panic) {
  329.                 clock2=15;
  330.                 ++panic;
  331.             }
  332.             msg=130;
  333.         }
  334.         else {
  335.             msg=34+prop[GRATE];
  336.             prop[GRATE] = (verb==LOCK ? 0 : 1);
  337.             msg += 2*prop[GRATE];
  338.         }
  339.         break;
  340.     default:
  341.         msg=33;
  342.     }
  343.     rspeak(msg);
  344. }
  345.  
  346. /*
  347.     SAY etc.
  348. */
  349. vsay()
  350. {
  351.     int wtype,wval;
  352.  
  353.     analyze(word1,&wtype,&wval);
  354.     printf("Okay.\n%s\n",wval==SAY ? word2 : word1);
  355. }
  356.  
  357. /*
  358.     ON etc.
  359. */
  360. von()
  361. {
  362.     if(!here(LAMP))
  363.         actspk(verb);
  364.     else if(limit<0)
  365.         rspeak(184);
  366.     else {
  367.         prop[LAMP]=1;
  368.         rspeak(39);
  369.         if(wzdark) {
  370.             wzdark=0;
  371.             describe();
  372.         }
  373.     }
  374. }
  375.  
  376. /*
  377.     OFF etc.
  378. */
  379. voff()
  380. {
  381.     if(!here(LAMP))
  382.         actspk(verb);
  383.     else {
  384.         prop[LAMP]=0;
  385.         rspeak(40);
  386.     }
  387. }
  388.  
  389. /*
  390.     WAVE etc.
  391. */
  392. vwave()
  393. {
  394.     if(!toting(object) &&
  395.        (object!=ROD || !toting(ROD2)))
  396.         rspeak(29);
  397.     else if(object!=ROD || !at(FISSURE) ||
  398.         !toting(object) || closing)
  399.         actspk(verb);
  400.     else {
  401.         prop[FISSURE] = 1-prop[FISSURE];
  402.         pspeak(FISSURE,2-prop[FISSURE]);
  403.     }
  404. }
  405.  
  406. /*
  407.     ATTACK, KILL etc.
  408. */
  409. vkill()
  410. {
  411.     char msg;
  412.     int i;
  413.  
  414.     switch(object) {
  415.     case BIRD:
  416.         if(closed)
  417.             msg=137;
  418.         else {
  419.             dstroy(BIRD);
  420.             prop[BIRD]=0;
  421.             if(place[SNAKE]==19)
  422.                 ++tally2;
  423.             msg=45;
  424.         }
  425.         break;
  426.     case 0:
  427.         msg=44;
  428.         break;
  429.     case CLAM:
  430.     case OYSTER:
  431.         msg=150;
  432.         break;
  433.     case SNAKE:
  434.         msg=46;
  435.         break;
  436.     case DWARF:
  437.         if(closed)
  438.             dwarfend();
  439.         msg=49;
  440.         break;
  441.     case TROLL:
  442.         msg=157;
  443.         break;
  444.     case BEAR:
  445.         msg=165+(prop[BEAR]+1)/2;
  446.         break;
  447.     case DRAGON:
  448.         if(prop[DRAGON]!=0) {
  449.             msg=167;
  450.             break;
  451.         }
  452.         if(!yes(49,0,0))
  453.             break;
  454.         pspeak(DRAGON,1);
  455.         prop[DRAGON]=2;
  456.         prop[RUG]=0;
  457.         move((DRAGON+MAXOBJ),-1);
  458.         move((RUG+MAXOBJ),0);
  459.         move(DRAGON,120);
  460.         move(RUG,120);
  461.         for(i=1;i<MAXOBJ;++i)
  462.             if(place[i]==119 || place[i]==121)
  463.                 move(i,120);
  464.         newloc=120;
  465.         return;
  466.     default:
  467.         actspk(verb);
  468.         return;
  469.     }
  470.     rspeak(msg);
  471. }
  472.  
  473. /*
  474.     POUR
  475. */
  476. vpour()
  477. {
  478.     if(object==BOTTLE || object==0)
  479.         object=liq(0);
  480.     if(object==0) {
  481.         needobj();
  482.         return;
  483.     }
  484.     if(!toting(object)) {
  485.         actspk(verb);
  486.         return;
  487.     }
  488.     if(object!=OIL && object!=WATER) {
  489.         rspeak(78);
  490.         return;
  491.     }
  492.     prop[BOTTLE]=1;
  493.     place[object]=0;
  494.     if(at(PLANT)) {
  495.         if(object!=WATER)
  496.             rspeak(112);
  497.         else {
  498.             pspeak(PLANT,prop[PLANT]+1);
  499.             prop[PLANT]=(prop[PLANT]+2)%6;
  500.             prop[PLANT2]=prop[PLANT]/2;
  501.             describe();
  502.         }
  503.     }
  504.     else if(at(DOOR)) {
  505.         prop[DOOR]=(object==OIL ? 1 : 0);
  506.         rspeak(113+prop[DOOR]);
  507.     }
  508.     else
  509.         rspeak(77);
  510. }
  511.  
  512. /*
  513.     EAT
  514. */
  515. veat()
  516. {
  517.     char msg;
  518.  
  519.     switch(object) {
  520.     case FOOD:
  521.         dstroy(FOOD);
  522.         msg=72;
  523.         break;
  524.     case BIRD: case SNAKE: case CLAM: case OYSTER:
  525.     case DWARF: case DRAGON: case TROLL: case BEAR:
  526.         msg=71;
  527.         break;
  528.     default:
  529.         actspk(verb);
  530.         return;
  531.     }
  532.     rspeak(msg);
  533. }
  534.  
  535. /*
  536.     DRINK
  537. */
  538. vdrink()
  539. {
  540.     if(object!=WATER)
  541.         rspeak(110);
  542.     else if(liq()!=WATER || !here(BOTTLE))
  543.         actspk(verb);
  544.     else {
  545.         prop[BOTTLE]=1;
  546.         place[WATER]=0;
  547.         rspeak(74);
  548.     }
  549. }
  550.  
  551. /*
  552.     THROW etc.
  553. */
  554. vthrow()
  555. {
  556.     char msg;
  557.     int i;
  558.  
  559.     if(toting(ROD2) && object==ROD && !toting(ROD))
  560.         object=ROD2;
  561.     if(!toting(object)) {
  562.         actspk(verb);
  563.         return;
  564.     }
  565.     /*
  566.        treasure to troll
  567.     */
  568.     if(at(TROLL) && object >= 50 && object<MAXOBJ) {
  569.         rspeak(159);
  570.         drop(object,0);
  571.         move(TROLL,0);
  572.         move((TROLL+MAXOBJ),0);
  573.         drop(TROLL2,117);
  574.         drop((TROLL2+MAXOBJ),122);
  575.         juggle(CHASM);
  576.         return;
  577.     }
  578.     /*
  579.        feed the bears...
  580.     */
  581.     if(object==FOOD && here(BEAR)) {
  582.         object=BEAR;
  583.         vfeed();
  584.         return;
  585.     }
  586.     /*
  587.        if not axe, same as drop...
  588.     */
  589.     if (object!=AXE) {
  590.         vdrop();
  591.         return;
  592.     }
  593.     /*
  594.        AXE is THROWN
  595.     */
  596.     /*
  597.        at a dwarf...
  598.     */
  599.     if(i=dcheck()) {
  600.         msg=48;
  601.         if(pct(33)) {
  602.             dseen[i]=dloc[i]=0;
  603.             msg=47;
  604.             ++dkill;
  605.             if(dkill==1)
  606.                 msg=149;
  607.         }
  608.     }
  609.     /*
  610.        at a dragon...
  611.     */
  612.     else if(at(DRAGON) && prop[DRAGON]==0) 
  613.         msg=152;
  614.     /*
  615.        at the troll...
  616.     */
  617.     else if(at(TROLL))
  618.         msg=158;
  619.     /*
  620.        at the bear...
  621.     */
  622.     else if(here(BEAR) && prop[BEAR]==0) {
  623.         rspeak(164);
  624.         drop(AXE,loc);
  625.         fixed[AXE]=-1;
  626.         prop[AXE]=1;
  627.         juggle(BEAR);
  628.         return;
  629.     }
  630.     /*
  631.        otherwise it is an attack
  632.     */
  633.     else {
  634.         verb=KILL;
  635.         object=0;
  636.         itverb();
  637.         return;
  638.     }
  639.     /*
  640.        handle the left over axe...
  641.     */
  642.     rspeak(msg);
  643.     drop(AXE,loc);
  644.     describe();
  645. }
  646.  
  647. /*
  648.     INVENTORY, FIND etc.
  649. */
  650. vfind()
  651. {
  652.     char msg;
  653.     if(toting(object))
  654.         msg=24;
  655.     else if(closed)
  656.         msg=138;
  657.     else if(dcheck() && dflag >= 2 && object==DWARF)
  658.         msg=94;
  659.     else if (at(object) ||
  660.         (liq()==object && here(BOTTLE)) ||
  661.         object==liqloc(loc))
  662.         msg=94;
  663.     else {
  664.         actspk(verb);
  665.         return;
  666.     }
  667.     rspeak(msg);
  668. }
  669.  
  670. /*
  671.     FILL
  672. */
  673. vfill()
  674. {
  675.     char msg;
  676.     int i;
  677.  
  678.     switch(object) {
  679.     case BOTTLE:
  680.         if(liq()!=0)
  681.             msg=105;
  682.         else if(liqloc(loc)==0)
  683.             msg=106;
  684.         else {
  685.             prop[BOTTLE]=cond[loc] & WATOIL;
  686.             i=liq();
  687.             if(toting(BOTTLE))
  688.                 place[i]=-1;
  689.             msg=(i==OIL ? 108 : 107);
  690.         }
  691.         break;
  692.     case VASE:
  693.         if(liqloc(loc)==0) {
  694.             msg=144;
  695.             break;
  696.         }
  697.         if(!toting(VASE)) {
  698.             msg=29;
  699.             break;
  700.         }
  701.         rspeak(145);
  702.         vdrop();
  703.         return;
  704.     default:
  705.         msg=29;
  706.     }
  707.     rspeak(msg);
  708. }
  709.  
  710. /*
  711.     FEED
  712. */
  713. vfeed()
  714. {
  715.     char msg;
  716.  
  717.     switch(object) {
  718.     case BIRD:
  719.         msg=100;
  720.         break;
  721.     case DWARF:
  722.         if(!here(FOOD)) {
  723.             actspk(verb);
  724.             return;
  725.         }
  726.         ++dflag;
  727.         msg=103;
  728.         break;
  729.     case BEAR:
  730.         if(!here(FOOD)) {
  731.             if(prop[BEAR]==0)
  732.                 msg=102;
  733.             else if(prop[BEAR]==3)
  734.                 msg=110;
  735.             else {
  736.                 actspk(verb);
  737.                 return;
  738.             }
  739.         break;
  740.         }
  741.         dstroy(FOOD);
  742.         prop[BEAR]=1;
  743.         fixed[AXE]=0;
  744.         prop[AXE]=0;
  745.         msg=168;
  746.         break;
  747.     case DRAGON:
  748.         msg=(prop[DRAGON]!=0 ? 110 : 102);
  749.         break;
  750.     case TROLL:
  751.         msg=182;
  752.         break;
  753.     case SNAKE:
  754.         if(closed || !here(BIRD)) {
  755.             msg=102;
  756.             break;
  757.         }
  758.         msg=101;
  759.         dstroy(BIRD);
  760.         prop[BIRD]=0;
  761.         ++tally2;
  762.         break;
  763.     default:
  764.         msg=14;
  765.     }
  766.     rspeak(msg);
  767. }
  768.  
  769. /*
  770.     READ etc.
  771. */
  772. vread()
  773. {
  774.     char msg;
  775.  
  776.     msg=0;
  777.     if(dark()) {
  778.         printf("I see no %s here.\n",probj(object));
  779.         return;
  780.     }
  781.     switch(object) {
  782.     case MAGAZINE:
  783.         msg=190;
  784.         break;
  785.     case TABLET:
  786.         msg=196;
  787.         break;
  788.     case MESSAGE:
  789.         msg=191;
  790.         break;
  791.     case OYSTER:
  792.         if(!toting(OYSTER) || !closed)
  793.             break;
  794.         yes(192,193,54);
  795.         return;
  796.     default:
  797.         ;
  798.     }
  799.     if(msg)
  800.         rspeak(msg);
  801.     else
  802.         actspk(verb);
  803. }
  804.  
  805. /*
  806.     BLAST etc.
  807. */
  808. vblast()
  809. {
  810.     if (prop[ROD2] < 0 || !closed)
  811.         actspk(verb);
  812.     else {
  813.         bonus=133;
  814.         if (loc == 115)
  815.             bonus=134;
  816.         if (here(ROD2))
  817.             bonus = 135;
  818.         rspeak(bonus);
  819.         normend();
  820.     }
  821. }
  822.  
  823. /*
  824.     BREAK etc.
  825. */
  826. vbreak()
  827. {
  828.     char msg;
  829.     if (object == MIRROR) {
  830.         msg=148;
  831.         if (closed) {
  832.             rspeak(197);
  833.             dwarfend();
  834.         }
  835.     }
  836.     else if (object==VASE && prop[VASE]==0) {
  837.         msg=198;
  838.         if (toting(VASE))
  839.             drop(VASE,loc);
  840.         prop[VASE]=2;
  841.         fixed[VASE]=-1;
  842.     }
  843.     else {
  844.         actspk(verb);
  845.         return;
  846.     }
  847.     rspeak(msg);
  848. }
  849.  
  850. /*
  851.     WAKE etc.
  852. */
  853. vwake()
  854. {
  855.     if (object!=DWARF || !closed)
  856.         actspk(verb);
  857.     else {
  858.         rspeak(199);
  859.         dwarfend();
  860.     }
  861. }
  862.  
  863. /*
  864.     Routine to speak default verb message
  865. */
  866. actspk(verb)
  867. int verb;
  868. {
  869.     char i;
  870.  
  871.     if(verb<1 || verb>31)
  872.         bug(39);
  873.     i=actmsg[verb];
  874.     if(i)
  875.         rspeak(i);
  876. }
  877.  
  878. /*
  879.     Routine to indicate no reasonable
  880.     object for verb found.  Used mostly by
  881.     intransitive verbs.
  882. */
  883. needobj()
  884. {
  885.     int wtype,wval;
  886.  
  887.     analyze(word1,&wtype,&wval);
  888.     printf("%s what?\n",wtype==2 ? word1 : word2);
  889. }
  890.